/**
 * @name axiosIns
 * @desc axios 二次封装
 * @author darcrand
 */

import axios from "axios"
// import qs from "qs"

const axiosIns = axios.create({
    baseURL: "/api",
    timeout: 10000,
    responseType: "json",
    // transformRequest: [data => qs.stringify(data)],
    headers: {
        "Content-Type": "application/json;charset=utf-8"
    }
})

axiosIns.interceptors.request.use(
    config => {
        return config
    },
    error => Promise.reject(error)
)

axiosIns.interceptors.response.use(result => result.data, error => Promise.reject(error))

const get = (url, params = null, config = {}) => axiosIns.get(url, { ...config, params })
const post = axiosIns.post
const all = axiosIns.all
export { get, post, all }
